package com.example.practical_training_projects.mapper;

import com.example.practical_training_projects.entity.questionform;
import com.example.practical_training_projects.entity.user;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface questionformMapper {
    @Select("select * from questionform")
    List<questionform> getAllQF();
    //增加
    @Insert("insert into questionform (q_name,q_context,q_context1,q_category)\n" +
            " values (#{q_name},#{q_context},#{q_context1},#{q_category})")
    Integer insertQF(questionform qf);
    //删除
    @Delete("delete from questionform where q_uid=#{q_uid}")
    Integer deleteQF(Integer qf);
    //更新
    @Update("update questionform set q_name=#{q_name},q_context=#{q_context}, q_dianzan=#{q_dianzan},q_context1=#{q_context1} where q_uid = #{q_uid}")
    Integer updateQF(questionform qf);
    @Select("select *from questionform where q_name like '%${q_name}%'")
    List<questionform>  getQFBYName(String q_name);

    @Select("select * from  questionform where q_uid = #{q_uid}")
    questionform findQFuid(Integer q_uid);


    @Select("<script>" +
            "SELECT * FROM questionform WHERE 1=1" +
            "<if test='search!=null and search!=\"\"'>" +
            " AND (" +
            "q_name LIKE CONCAT('%', #{search}, '%') OR " +
            "q_context LIKE CONCAT('%', #{search}, '%') OR " +
            "q_context1 LIKE CONCAT('%', #{search}, '%') OR " +
            "q_category LIKE CONCAT('%', #{search}, '%')" +
            ")</if>" +
            "</script>")
    List<questionform> getQuestionsByMultiCriteria(@Param("search") String search);




}
